import subprocess
w = input("请输入要检查的网段:")
with open("ip.txt","w",encoding='utf-8') as f:
    for i in range(0,255):
        a = "ping -c 1 192.168.0.{}".format(i)
        child = subprocess.run(a,shell=True)
        data = child.returncode
        print(data)
        if data == 0:
            f.write(a+"已使用"+'\n')

